package com.sinping.qh.query.document;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;
import org.apache.commons.collections.map.HashedMap;

import java.util.HashMap;
import java.util.Map;

@Data
public class DocumentQuery implements QueryParams {

    private String fileName;

    private String fileType;

    private String status;

    static Map<String,String> aliasMap = new HashMap<>();
    static Map<String,Operator> operateMap = new HashMap<>();

    static {
        aliasMap.put("fileName","file_name");
        aliasMap.put("fileType","file_type");

        operateMap.put("fileName",Operator.regex);
        operateMap.put("fileType",Operator.eq);
        operateMap.put("status",Operator.eq);
    }


    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName,fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operateMap.getOrDefault(fieldName,Operator.eq);
    }
}
